package moonlit.chill.pay.asyncFactory;

import cn.hutool.extra.spring.SpringUtil;
import lombok.extern.slf4j.Slf4j;
import moonlit.chill.pay.asyncFactory.service.AsyncTaskService;
import moonlit.chill.pay.vo.PayResult;
import moonlit.chill.pay.vo.TradeParam;

import java.util.TimerTask;

/**
 * @author MoonlitChill
 * @date 2024/4/24 16:01
 */
@Slf4j
public class AsyncFactory {

    public static TimerTask payQuerySuccess(PayResult<?> result, TradeParam tradeParam) {
        return new TimerTask() {
            @Override
            public void run() {
                SpringUtil.getBean(AsyncTaskService.class).payQuerySuccess(result, tradeParam);
            }
        };
    }

    public static TimerTask launchPaySuccessHandle(PayResult<?> result, TradeParam tradeParam) {
        return new TimerTask() {
            @Override
            public void run() {
                SpringUtil.getBean(AsyncTaskService.class).launchPaySuccessHandle(result, tradeParam);
            }
        };
    }
}
